<template>
	<view class="content1 f-dc">
		<u-navbar :fixed="false" :title="titleName" :autoBack="true" :safeAreaInsetTop="true" leftIconColor="#fff">
			<view slot="right">
				<m-bubble type="list" :selectData="formMenus" position="right" topOpsotion="right" bgcRgba="#fff"
					color="#333" @selectFun="TapPopup">
					<u-icon name="more-dot-fill" color="#fff" class="moremenu"></u-icon>
				</m-bubble>
			</view>
		</u-navbar>
		<view class="MainBox1" v-if="isShowMainForm" :style="{flex: childFormList.length ? 'none' : 1}">
			<u--form labelPosition="left" :model="formData" ref="uForm" labelWidth="100"
				:labelStyle="{fontSize:'14px',fontWeight:600}">
				<u-form-item labelWidth="100" :label="row.baseProperty.labelName" prop="name" borderBottom
					:required="row.baseProperty.isRequired" v-if="row.baseProperty.controlType != 'hidden'"
					v-for="(row,index) in formDesign">

					<view v-if="row.baseProperty.controlType == 'datepicker'" @click="clickDatePicker(row)"
						style="width:100%">
						<u--input v-model="formData[row.baseProperty.controlName]" :ref="row.baseProperty.controlName"
							:readonly="true" border="none" v-if="row.baseProperty.controlType == 'datepicker'"
							suffixIcon="calendar"></u--input>
					</view>
					<view v-else-if="row.baseProperty.controlType=='select' && row.controlProperty.select.type == 1"
						@click="openBaseScreen(row)" style="width:100%">
						<u--input v-model="formData[row.baseProperty.controlName+'_show']"
							:name="row.baseProperty.controlName" suffixIcon="arrow-right" border="none"
							:readonly="true"></u--input>
					</view>
					<view v-else-if="row.baseProperty.controlType=='select' && row.controlProperty.select.type == 3"
						@click="openBaseScreen(row)" style="width:100%">
						<u--input v-model="formData[row.baseProperty.controlName+'_show']"
							:name="row.baseProperty.controlName" suffixIcon="arrow-right" border="none"
							:readonly="true"></u--input>
					</view>
					<u--input type="number" v-model="formData[row.baseProperty.controlName]" @change="dataChange(row)"
						:name="row.baseProperty.controlName" border="none" :readonly="row.baseProperty.isReadOnly"
						v-else-if="row.baseProperty.controlType == 'number'"
						:suffixIcon="row.baseProperty.isReadOnly ? '' : 'edit-pen-fill'"></u--input>
					<u-textarea v-model="formData[row.baseProperty.controlName]" :name="row.baseProperty.controlName"
						border="none" :readonly="row.baseProperty.isReadOnly" @change="dataChange(row)"
						v-else-if="row.baseProperty.controlType == 'textarea'"
						:suffixIcon="row.baseProperty.isReadOnly ? '' : 'edit-pen-fill'"></u-textarea>
					<u--input type="text" v-model="formData[row.baseProperty.controlName]"
						:name="row.baseProperty.controlName" border="none" :readonly="row.baseProperty.isReadOnly"
						@change="dataChange(row)" v-else-if="row.baseProperty.controlType == 'textbox'"
						:suffixIcon="row.baseProperty.isReadOnly ? '' : 'edit-pen-fill'"></u--input>
					<view v-else-if="row.baseProperty.controlType=='fileUpload'" style="width:100%">
						<u-upload :fileList="getformDataFile(row)" :beforeRead="beforeReadHandler"
							@delete="deleteUploadFile" :disabled="row.baseProperty.isReadOnly"
							:multiple="row.controlProperty.upload.isMulti"
							:name="row.baseProperty.controlName"></u-upload>
					</view>
				</u-form-item>
			</u--form>
		</view>
		<u-gap height="1" bgColor="#dadada"></u-gap>
		<!-- <view class="f-dc" :class="isShowMainForm?'DetailBox':'DetailBoxFull'"> -->
		<view class="f-dc" style="overflow: auto;" :style="{flex: childFormList.length ?   1:'none'}">
			<!-- <u-icon name="order" ></u-icon> -->
			<!-- 导入数据，添加子表 -->


			<u-sticky bgColor="#fff">
				<u-row customStyle="margin-bottom: 10px" v-if="importConfig && filterImportConfigList().length>0">
					<u-col :span="12/filterImportConfigList().length" v-for="importItem in filterImportConfigList()"
						style="display: flex;justify-content: center;align-items: center;">
						<u-icon name="order" color="#51d0d0" size="20" style="padding:15px 0px 5px 5px;"
							:label="importItem.btnName" labelSize="16" labelColor="#51d0d0"
							@click="importData(importItem)"></u-icon>
					</u-col>
				</u-row>
				<u-gap height="1" bgColor="#dadada" v-if="importConfig && filterImportConfigList().length>0"></u-gap>
				<u-tabs :list="TabList" :current="tabCurrent" @click="clickTabItem"></u-tabs>

			</u-sticky>
			<!-- <view :class="isShowMainForm?'Main_CardListBox':'Main_CardListBoxFull'" -->
			<view v-for="(childForm,index) in childFormList">
				<u-empty mode="history" text="列表数据为空" marginTop="50"
					v-if="childForm.tableData && childForm.tableData.length==0 && childForm.title == TabList[tabCurrent]['name']">
				</u-empty>

				<u-swipe-action v-show="childForm.title == TabList[tabCurrent]['name']">
					<u-swipe-action-item :options="deleteOper" v-for="(item,idx) in childForm.tableData" :name="idx"
						@click="delRow(childForm,item)" ref="delSwiper" style="margin-bottom: 10rpx;">
						<view class="content_main_CardBox" @click="openEditWin(item,childForm)">
							<view class="FiledBox">
								<text class="FiledBox_label_f18" v-if="childForm.titleCol.colType!=2"><text
										class="van-badge">{{ idx+1 }}</text>
									{{ item[childForm.titleCol.colName]}}</text>
								<text class="FiledBox_label_f18" v-else="childForm.titleCol.colType==2"><text
										class="van-badge">{{ idx+1 }}</text>
									{{ showActualValue(item[childForm.titleCol.colName],childForm.titleCol ) }}</text>
								<!-- <u-icon name="trash-fill" style="position: absolute;right:15px;" size="18"></u-icon> -->
							</view>
							<view style="clear: both;"></view>
							<view class="content_main_CardBox_RightTop y-end"
								style="position: absolute;right: 20rpx;top: 50%;">
								<view class="FiledBox">
									<u-icon name="arrow-right"></u-icon>
								</view>
							</view>

							<view class="FiledBox" v-for="col in childForm.columns"
								v-if="!col.isHidden && !col.isTitle">
								<text style="color:red"
									:style="{visibility: col.isRequired ? 'initial':'hidden'}">*</text>
								<text class="FiledBox_label_f14 FiledBox_grifola">{{ col.colDesc }}:</text>
								<text class="FiledBox_value FiledBox_value_f14 FiledBox_grifola"
									v-if="col.colType!=2">{{item[col.colName] }}</text>
								<text class="FiledBox_value FiledBox_value_f14 FiledBox_grifola"
									v-if="col.colType==2">{{showActualValue(item[col.colName],col) }}</text>
							</view>
						</view>
						<view class="childBtns">
							<u-button v-for="work in childForm.workList" color="#51d0d0"
								v-if="btn_showConditionByChild(work)" @click="selfChildWorkHandler(work,item)"
								type="primary" size="small" :text="work.name"
								style="width:auto;margin-right:10px;"></u-button>
						</view>
					</u-swipe-action-item>
				</u-swipe-action>
			</view>
		</view>


		<view class="content_bottom1 x-ec " :style="$utils.disposeSafeBottomFun()">

			<button v-if="!isUpdate" class="CommonBtnSize workBtn" plain @click="saveDraftInfo">保存草稿</button>

			<!-- content_bottom_primary_Btn -->
			<button class="CommonBtnSize workBtn" plain v-for="btn in workList" style="margin-left: 10px;"
				v-if="btn_showCondition(2,btn)" @click="selfWorkHandler(btn)">
				{{ btn.name }}
			</button>

			<button class="CommonBtnSize content_bottom_primary_Btn" style="margin-left: 10px;"
				v-if="!isUpdate && btn_showCondition(1,'新增')" @click="saveRow">提交</button>
			<button class="CommonBtnSize content_bottom_primary_Btn" style="margin-left: 10px;"
				v-if="isUpdate && btn_showCondition(1,'编辑')" @click="saveRow">提交</button>
		</view>
		<!-- 日期控件 -->
		<u-datetime-picker style="z-index: 9999999;" :maxDate="maxOickerDateTime" :show="showDatePicker"
			v-model="curDate" mode="date" :formatter="formatterDate" @confirm="onDatePickerConfirm"
			@cancel="showDatePicker=false,curDate=''" :closeOnClickOverlay="true"></u-datetime-picker>
		<u-datetime-picker style="z-index: 9999999;" :maxDate="maxOickerDateTime" :show="showDatePicker2"
			v-model="curDate2" mode="date" :formatter="formatterDate" @confirm="onDatePickerConfirm2"
			@cancel="showDatePicker2=false,curDate2=''" :closeOnClickOverlay="true"></u-datetime-picker>
		<!-- 弹出框 -->
		<u-popup :show="showEditWin" mode="bottom" @close="closeEditWin">
			<view class="editDetail f-dc" :style="$utils.disposeSafeBottomFun()">
				<view style="flex:1;overflow: auto;width: 100%;padding: 10px 10px 10px 15px;">
					<u--form labelPosition="left" :model="editValues" ref="dForm" labelWidth="100">
						<u-form-item :label="row.colDesc" borderBottom :required="row.isRequired" v-if="!row.isHidden"
							v-for="(row,index) in editFrame.columns">

							<view v-if="row.colType==3" @click="clickDatePicker2(row)" style="width:100%">
								<u--input v-if="row.colType==3" v-model="editValues[row.colName]" readonly
									:ref="row.colName" inputAlign="right" border="none"></u--input>
							</view>
							<view v-else-if="row.colType==2  && row.selDetail.type==1" @click="openBaseScreen2(row)"
								style="width:100%">
								<u--input :value="showActualValue(editValues[row.colName],row)" inputAlign="right"
									:name="row.colName" :suffixIcon="row.isReadOnly ? 'none' : 'arrow-right'"
									border="none" :readonly="true"></u--input>
							</view>
							<view v-else-if="row.colType==2  && row.selDetail.type==3" @click="openBaseScreen2(row)"
								style="width:100%">
								<u--input :value="showActualValue(editValues[row.colName],row)" inputAlign="right"
									:name="row.colName" :suffixIcon="row.isReadOnly ? 'none' : 'arrow-right'"
									border="none" :readonly="true"></u--input>
							</view>
							<u--input v-else-if="row.colType == 4" type="number" v-model="editValues[row.colName]"
								inputAlign="right" :name="row.colName"
								@change="itemDataChange(row,editValues,editFrame,editValues[row.colName])" border="none"
								:readonly="row.isReadOnly"
								:suffixIcon="row.isReadOnly ? 'none' : 'edit-pen-fill'"></u--input>
							<u--input v-else-if="row.colType == 1" type="text" v-model="editValues[row.colName]"
								inputAlign="right" :name="row.colName"
								@change="itemDataChange(row,editValues,editFrame,editValues[row.colName])" border="none"
								:readonly="row.isReadOnly"
								:suffixIcon="row.isReadOnly ? 'none' : 'edit-pen-fill'"></u--input>
						</u-form-item>
					</u--form>

				</view>
				<view style="height: 70px;">
					<button class="CommonBtnSize content_bottom_primary_Btn"
						style="margin: 10px auto 0;width:calc(100% - 40px); " @click="closeEditWin">确定</button>
				</view>
			</view>
		</u-popup>
		<!-- pda_tc80 -->
		<m-pda-scancode v-if="$utils.isPda()" listenName="pdaScanCode"
			:SetContent="{action:'com.android.decodewedge.decode_action',extra:'com.android.decode.intentwedge.barcode_string'}"></m-pda-scancode>

		<!-- pda_tc27 -->
		<m-pda-scancode v-if="$utils.isPda()" listenName="pdaScanCode"
			:SetContent="{action:'android.intent.action.SCANRESULT',extra:'value'}"></m-pda-scancode>
	</view>
</template>

<script>
	import {
		isNumber
	} from 'util';

	import layerFun from '@/common/comFun/layerFun.js';
	var layer = layerFun;

	import APPFun from '@/common/comFun/APPFun.js';
	var APP = APPFun;


	import DB from '@/common/comFun/sqlite.js'

	var vm;
	export default {
		data() {
			return {
				origin: '', // 来源界面
				idByDraftList: '', // 主键id，；来源-草稿箱
				titleName: '编辑',
				detailName: '',
				physicalTableName: '',
				keyName: '',
				keyValue: '',
				mainTitle: '',
				mainForm: [],
				tagForm: [],
				formData: {
					name: "测试"
				},
				editValues: {},
				formMenus: [{
						name: '隐藏表头',
						value: '',
						icon: 'order'
					},
					{
						name: '扫码',
						value: '',
						icon: 'scan'
					},
					{
						name: '刷新',
						value: '',
						icon: 'reload'
					}
				],

				pageWhere: [0, 0, 0], // 记录切换tab后，前一项所在位置
				tabCurrent: 0, // 选中tab项索引
				TabList: [],
				childFormList: [],
				changeDataSource: [],
				workList: [],
				crudList: [],
				importConfig: [],
				formDesign: [],
				isShowMainForm: true,
				showEditWin: false,
				editFrame: {},
				//下拉控件
				windowSelectType: 1,
				curSelectWindowObj: {},
				curSelectWindowObj2: {},

				//日期控件
				showDatePicker: false,
				curDate: '',
				curDateObj: '',
				showDatePicker2: false,
				curDate2: '',
				curDateObj2: '',
				isUpdate: false,
				enabledSubmitBtn: true,
				deleteOper: [{
					icon: 'trash-fill',
					style: {
						backgroundColor: '#ff0000',
						color: '#fff'
					}
				}],
				scanConfig: null, // 扫码配置
				printConfig: null, //打印配置
				onReadyCallBack: null, // 加载完成后
				childListData: [], // 加载完成后插入的数据
				waitKeyName: '',
				columns: [],
				childObj: {},
				tableKeyName: '', //表名
			};
		},
		onUnload() {
			uni.$off('importData');
			uni.$off('selectPicker_formEdit');
		},
		onReady() {
			uni.$on('pdaScanCode', function(content) {
				vm.dealScan(content);
			})
			//弹窗下拉数据选择
			uni.$on('selectPicker_formEdit', function(data) {
				console.log(data)

				var ret = data.data;
				//主表表单选择
				if (vm.windowSelectType == 1) {
					if (ret) {
						vm.formData[vm.curSelectWindowObj.baseProperty.controlName] = ret[vm.curSelectWindowObj
							.controlProperty.select.hiddenValue];
						//vm.formData[vm.curSelectWindowObj.baseProperty.controlName + '_show'] = ret[vm.curSelectWindowObj.controlProperty.select.displayValue];
						vm.$set(vm.formData, vm.curSelectWindowObj.baseProperty.controlName + '_show', ret[vm
							.curSelectWindowObj.controlProperty.select.displayValue]);
						vm.dataChange(vm.curSelectWindowObj, ret);
						vm.curSelectWindowObj = '';
					} else {
						vm.formData[vm.curSelectWindowObj.baseProperty.controlName] = '';
						vm.$set(vm.formData, vm.curSelectWindowObj.baseProperty.controlName + '_show', '');
						vm.dataChange(vm.curSelectWindowObj, ret);
						vm.curSelectWindowObj = '';
					}
					vm.$forceUpdate();
				} else if (vm.windowSelectType == 2) {
					if (ret) {
						vm.editValues[vm.curSelectWindowObj2.colName] = ret[vm.curSelectWindowObj2.selDetail
							.hiddenValue];
						//vm.formData[vm.curSelectWindowObj.baseProperty.controlName + '_show'] = ret[vm.curSelectWindowObj.controlProperty.select.displayValue];
						vm.$set(vm.editValues, vm.curSelectWindowObj2.colName + '_show', ret[vm.curSelectWindowObj2
							.selDetail.displayValue]);
						vm.editValues[vm.curSelectWindowObj2.colName + '_show', ret[vm.curSelectWindowObj2
							.selDetail.displayValue]];
						vm.itemDataChange(vm.curSelectWindowObj2, vm.editValues, vm.editFrame, ret);
						vm.curSelectWindowObj2 = '';
					} else {
						vm.editValues[vm.curSelectWindowObj2.colName] = '';
						vm.$set(vm.editValues, vm.curSelectWindowObj2.colName + '_show', '');
						vm.itemDataChange(vm.curSelectWindowObj2, vm.editValues, vm.editFrame, ret);
						vm.curSelectWindowObj2 = '';
					}
					vm.refreshEditValueCol(vm.editFrame);
					vm.$forceUpdate();
				}
			})

			uni.$on('importData', function(importValue) {
				console.log(importValue)
				let columns = importValue.columns;
				let selections = importValue.selections;

				var colToColumnList = columns.filter(function(item) {
					return item.colToColumn != undefined && item.colToColumn !== ""
				});
				var isMain = false;
				var mainCount = 0;
				var childFormDatas = [];


				for (var z = 0; z < vm.childFormList.length; z++) {
					childFormDatas.push({
						name: vm.childFormList[z].title,
						frameName: vm.childFormList[z].name,
						record: []
					});
				}
				for (var i = 0; i < selections.length; i++) {
					for (var j = 0; j < colToColumnList.length; j++) {
						var toColumnNames = colToColumnList[j].colToColumn.split(',');
						console.log(toColumnNames)
						for (var k = 0; k < toColumnNames.length; k++) {
							var nameKey = toColumnNames[k].split('.')[0];
							var nameValue = toColumnNames[k].split('.')[1];
							//主记录数据
							if (nameKey == "main" && !isMain) {
								mainCount++;
								if (vm.formData[nameValue] != undefined) {
									vm.formData[nameValue] = selections[i][colToColumnList[j].colName];
									//vm.execChangeEvent(colToColumnList[j].colName, 1);
									//vm.execChangeEvent(colToColumnList[j].colName, 2);
								}
							}
							if (nameKey != "main") {
								var recordList = childFormDatas.filter(function(item) {
									return item.name == nameKey || item.frameName == nameKey
								});
								if (recordList.length > 0) {
									for (var r = 0; r < recordList.length; r++) {
										if (recordList[r].record[i] == undefined) {
											recordList[r].record[i] = {};
										}
										recordList[r].record[i][nameValue] = selections[i][colToColumnList[j]
											.colName
										];
									}
								}
							}
						}
					}
					if (mainCount > 0) {
						isMain = true;
					}
				}
				//vm.refreshInitActualName();
				console.log(childFormDatas)
				//插入子表数据
				for (var i = 0; i < childFormDatas.length; i++) {
					if (childFormDatas[i].record.length > 0) {
						if (JSON.stringify(childFormDatas[i].record) != "{}") {
							//插入子表
							vm.insertImportData(childFormDatas[i].frameName, childFormDatas[i].record);
						}
					}
				}
			});
		},
		onLoad(option) {
			var that = this;
			vm = that;
			//详情页对象名称，具体id值
			let menuDetailObj = this.$store.state.MenuDetail;

			console.log(option)
			if (!this.$utils.isEmpty(option)) {
				// 判断来源
				if (option.origin == 'draft') { // 草稿箱
					this.origin = 'draft';


					this.idByDraftList = menuDetailObj.id; // 赋值草稿主键ID
				}
			}

			that.detailName = menuDetailObj.detailName;
			that.keyName = menuDetailObj.keyName;
			that.keyValue = menuDetailObj.keyValue;
			that.titleName = menuDetailObj.detailTitle.replace('列表', '') + '编辑';
			that.mainTitle = menuDetailObj.dataInfo.titleColName;
			that.mainForm = menuDetailObj.dataInfo.showColumnsInfo;
			that.tagForm = menuDetailObj.dataInfo.tagColumnsInfo;

			// 给待办用的，暂时这么写
			that.childListData = menuDetailObj.dataInfo.childListData || [];
			that.waitKeyName = menuDetailObj.dataInfo.waitKeyName || '';

			let UserInfo = JSON.parse(this.Request.UserInfo());
			// 表名
			this.tableKeyName = 'appAccount_' + UserInfo.Business + '_' + UserInfo.UserID;
			this.openSQL();

			that.initConfig(that.detailName);
		},
		computed: {
			maxOickerDateTime() { // 日期控件最大时间
				let now = new Date();

				// 增加一百年  
				now.setFullYear(now.getFullYear() + 100);

				// 将Date对象转换为时间戳  
				return now.getTime();
			},
		},
		methods: {
			// 打开数据库
			openSQL() {
				// 这个是查询有没有打开数据库
				let open = DB.isOpen();
				console.log("数据库状态", open ? "开启" : "关闭");
				if (!open) {
					DB.openSqlite()
						.then(res => {
							console.log("数据库已打开");
						})
						.catch(error => {
							console.log("数据库开启失败");
						});
				}
			},
			// 关闭数据库
			closeSQL() {
				// 这个是查询有没有打开数据库
				let open = DB.isOpen();
				if (open) {
					DB.closeSqlite()
						.then(res => {
							console.log("数据库已关闭");
						})
						.catch(error => {
							console.log("数据库关闭失败");
						});
				}
			},
			async saveDraftInfo() { // 点击保存草稿按钮
				let that = this;
				that.$utils.showLoading();
				// 存储基础配置信息
				// 1、判断来源，如果是草稿箱来源，则删除数据库中该条数据，再插入
				if (!this.$utils.isEmpty(this.origin) && this.origin == 'draft' && !this.$utils.isEmpty(this
						.idByDraftList)) {
					// 删除本条数据
					console.log(11)
					console.log(this.idByDraftList)
					await this.deleteTableData(this.idByDraftList);
				}

				let newTableData = [];

				if (that.childFormList[0].tableData.length) {
					let childFormList_DataCoopy = that.$utils.deepClone(that.childFormList[0])

					newTableData = childFormList_DataCoopy['tableData'].map(item => {
						item['colInfo'] = [];

						return {
							...item
						}
					})
				}

				let open = DB.isOpen();
				if (open) {
					console.log(33)
					this.openSQL();
					let sql =
						'"id" INTEGER PRIMARY KEY AUTOINCREMENT,"detailTitle" text,"detailName" text,"keyName" text,"formData" text,"tableData" text,"CreatDate" text';
					// 创建表 DB.createTable(表名, 表的列)
					console.log(that.tableKeyName)
					DB.createTable(that.tableKeyName, sql)
						.then(res => {
							console.log("创建" + that.tableKeyName + "表成功");


							// 需要存储的数据

							let arr = [{
								detailTitle: that.titleName.replace('编辑', ''),
								detailName: that.detailName,
								keyName: that.keyName,
								formData: JSON.stringify(that.formData),
								tableData: JSON.stringify(newTableData),
							}]
							// 判断是否是草稿进来的，进行插入或更新数据
							that.insertTableData(arr);



						})
						.catch(error => {
							that.$utils.hideLoading();
							that.$utils.msg('保存失败');
							console.log(error);
							console.log("创建表失败");
						});
				} else {
					console.log("数据库未打开");
				}

			},
			// 新增表数据
			insertTableData(arr) {
				let that = this;
				let open = DB.isOpen();
				if (open) {
					arr.map(item => {
						let time = that.formatDate(new Date().getTime());
						let sql =
							`'${item.detailTitle}','${item.detailName}','${item.keyName}','${item.formData}','${item.tableData}','${time}'`;
						let condition = "'detailTitle','detailName','keyName','formData','tableData','CreatDate'";
						// 新增 DB.insertTableData(表名, 对应表头列的数据)
						DB.insertTableData(that.tableKeyName, sql, condition)
							.then(res => {
								console.log("新增数据成功");
								// 发起监听，刷新草稿箱数据

								that.$utils.hideLoading();
								uni.showToast({
									title: '保存成功'
								});
								uni.$emit('refreshDraftInfo');
							})
							.catch(error => {
								that.$utils.hideLoading();
								that.$utils.msg('保存失败');
								console.log("失败", error);
							});
					})
				} else {
					that.$utils.hideLoading();
					that.showToast("数据库未打开");
				}
			},

			// 删除表数据
			deleteTableData(id) {
				let open = DB.isOpen();
				if (open) {
					// 删除表 DB.deleteTableData(表名,查询条件列名,查询条件列值)
					DB.deleteTableData(this.tableKeyName, "id", id)
						.then(res => {
							this.showToast("删除表数据成功");
							this.idByDraftList = '';
						})
						.catch(error => {
							console.log("删除失败", error);
							that.$utils.hideLoading();
							that.$utils.msg('保存失败');
						});
				} else {
					that.$utils.hideLoading();
					this.showToast("数据库未打开");
				}
				console.log(22)
			},
			// 时间戳转年月日
			formatDate(data) {
				let now = new Date(data);
				var year = now.getFullYear(); //取得4位数的年份
				var month =
					now.getMonth() + 1 < 10 ?
					"0" + (now.getMonth() + 1) :
					now.getMonth() + 1;
				var date = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
				var hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
				var minute =
					now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
				var second =
					now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
				return (
					year +
					"-" +
					month +
					"-" +
					date +
					" " +
					hour +
					":" +
					minute +
					":" +
					second
				);
			},




			childFormListFun() {
				console.log(vm.childFormList)

				if (vm.childFormList.length) {
					return 'none'
				} else {
					return 1
				}
			},
			TapPopup(data) { // 选中气泡项
				let that = this;

				switch (data.name) {
					case '隐藏表头': {
						vm.isShowMainForm = false;
						vm.formMenus[0].name = "显示表头";
					}
					break;
					case '显示表头': {
						vm.isShowMainForm = true;
						vm.formMenus[0].name = "隐藏表头";
					}
					break;
					case '扫码': {
						// const type = 'CAMERA' // 权限名称，其他权限看下面文档
						// this.$refs.permissionDialog.requestPermission(type).then(() => {
						// 完成授权流程，开始业务代码
						uni.scanCode({
							success: function(res) {
								let searchValue = res.result;
								vm.dealScan(searchValue);
							}
						});
					}
					break;
					case '刷新': {
						that.initConfig(that.detailName);
					}
					break;
					default:
						break;
				}
			},
			clickTabItem(data) { // 点击Tab栏
				console.log(data)
				this.tabCurrent = data.index;
			},
			initConfig: function(objName, callBack) {
				var that = this;
				that.Request.requestByUrl('/AppFormDetail/GetDataByName', {
					objName: objName
				}, function(data) {
					vm.physicalTableName = data.ds[0].physicalTableName;
					console.log(that.keyName)
					console.log(that.keyValue)
					if (that.keyName && that.keyValue) {
						that.isUpdate = true;
						that.Request.requestByUrl("/SQLData/GetTableByKeyId", {
							physicalTableName: vm.physicalTableName,
							keyName: that.keyName,
							keyValue: that.keyValue
						}, function(ret) {
							if (ret.ds.length > 0) {
								var result = ret.ds[0];
								vm.formData = result;

								vm.tableConfig({
									childFormList: JSON.parse(data.ds[0].childFormsConfig),
									formDesign: JSON.parse(data.ds[0].formDesignConfig),
									physicalTableName: data.ds[0].physicalTableName,
									workList: JSON.parse(data.ds[0].worksConfig),
									crudList: JSON.parse(data.ds[0].crudConfig),
									importConfig: JSON.parse(data.ds[0].importConfig),
									scanConfig: data.ds[0].scanConfig,
									printConfig: data.ds[0].printConfig,
									onReadyCallBack: data.ds[0].onReadyCallBack
								});
								if (callBack) {
									callBack();
								}
								vm.enabledSubmitBtn = true;
							}
						});
					} else {
						vm.isUpdate = false;
						//设置默认值
						if (data.ds[0].formDesignConfig) {
							var newFormData = {};
							var designControls = JSON.parse(data.ds[0].formDesignConfig);
							for (var i = 0; i < designControls.length; i++) {
								if (designControls[i].baseProperty.defaultValue && designControls[i]
									.baseProperty.defaultValue.indexOf('@') < 0) {
									newFormData[designControls[i].baseProperty.controlName] = vm
										.getSYDefaultValue(designControls[i].baseProperty.defaultValue);
								} else if (designControls[i].baseProperty.defaultValue && designControls[i]
									.baseProperty.defaultValue.indexOf('@') >= 0) {
									var userInfo = vm.getSYDefaultValue(designControls[i].baseProperty
										.defaultValue);
									console.log(designControls[i].baseProperty
										.defaultValue)
									newFormData[designControls[i].baseProperty.controlName] = userInfo
										.P_UserID;
									newFormData[designControls[i].baseProperty.controlName + '_show'] =
										userInfo.P_UserName;
								} else {
									newFormData[designControls[i].baseProperty.controlName] = "";
								}
							}
							vm.formData = newFormData;
							if (that.origin == 'draft') { // 来源-草稿箱
								vm.formData = Object.assign(vm.formData, that.$store.state
									.MenuDetail.dataInfo.formData);

							} else {

								// 给待办用的，暂时这么写
								if (that.childListData.length) {
									if (that.childListData.length) {
										that.formData[that.waitKeyName] = that.childListData[0][that
											.waitKeyName
										]
									}
								}
							}

						}
						console.log(data)
						vm.tableConfig({
							childFormList: JSON.parse(data.ds[0].childFormsConfig),
							formDesign: JSON.parse(data.ds[0].formDesignConfig),
							physicalTableName: data.ds[0].physicalTableName,
							workList: JSON.parse(data.ds[0].worksConfig),
							crudList: JSON.parse(data.ds[0].crudConfig),
							importConfig: JSON.parse(data.ds[0].importConfig),
							scanConfig: data.ds[0].scanConfig,
							onReadyCallBack: data.ds[0].onReadyCallBack
						});
					}
				});
			},
			tableConfig(options) {
				let that = this;
				if (options.childFormList == null) {
					options.childFormList = [];
				}
				vm.workList = options.workList;
				vm.crudList = options.crudList;


				vm.onReadyCallBack = options.onReadyCallBack;
				vm.scanConfig = options.scanConfig;
				vm.printConfig = options.printConfig;
				vm.importConfig = options.importConfig;
				vm.childFormList = options.childFormList;
				console.log(vm.importConfig)
				console.log(vm.childFormList)
				vm.TabList = [];
				for (let i = 0; i < vm.childFormList.length; i++) {
					//子表数据列表刷新
					// vm.childFormList[i].showListLoading = false;
					// vm.childFormList[i].finished = false;
					//增加子表页签
					vm.TabList.push({
						name: vm.childFormList[i].title
					});
					//基础数据增删改查列表
					vm.childFormList[i].crud = {
						create: [],
						update: [],
						delete: []
					};
					vm.childFormList[i].fixedValues = {}
					vm.childPageInit(vm.childFormList[i]);
				}
				// vm.TabList.push({
				// 	name: '单据信息'
				// });

				for (var i = 0; i < options.formDesign.length; i++) {
					//日期控件，格式化内容
					if (options.formDesign[i].baseProperty.controlType == 'datepicker') {
						vm.formData[options.formDesign[i].baseProperty.controlName] = vm.formatterDate(vm.formData[options
								.formDesign[i].baseProperty.controlName], (options.formDesign[i].controlProperty
								.date && options.formDesign[i].controlProperty.date.type) ? "yyyy-MM-dd HH:mm:ss" :
							"yyyy-MM-dd");
					}
					if (options.formDesign[i].baseProperty.controlType == "select") {
						//下拉框数据加载
						if (options.formDesign[i].controlProperty.select.type < 3) {
							var sql = options.formDesign[i].controlProperty.select.dataSource;

							var formDesignObj = options.formDesign[i];
							vm.dealSelectDatasource(sql, formDesignObj);
						} else if (options.formDesign[i].controlProperty.select.type == 3) {
							if (options.formDesign[i].controlProperty.select.chooseType == 1) {
								var valueList = [];
								if (vm.formData[options.formDesign[i].baseProperty.controlName] != undefined && vm
									.formData[options.formDesign[i].baseProperty.controlName] !== "") {
									valueList.push("'" + vm.formData[options.formDesign[i].baseProperty.controlName] +
										"'");
								}
								var sql = "select * from (" + options.formDesign[i].controlProperty.select.dataSource +
									")t";
								if (valueList.length > 0) {
									sql += " where " + options.formDesign[i].controlProperty.select.hiddenValue + " in (" +
										valueList.join(',') + ") ";
									var formDesignObj = options.formDesign[i];
									vm.dealSelectDatasourceByTree(sql, formDesignObj);
								} else {
									vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", []);
									vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", []);
									vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");
									vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = '';
								}
							} else {
								var valueList = "";
								if (vm.formData[options.formDesign[i].baseProperty.controlName] != undefined && vm
									.formData[options.formDesign[i].baseProperty.controlName] !== "") {
									let valueArray = [];
									valueArray = vm.formData[options.formDesign[i].baseProperty.controlName].toString()
										.split(',');
									for (var q = 0; q < valueArray.length; q++) {
										valueArray[q] = "'" + valueArray[q] + "'";
									}
									valueList = valueArray.join(',');
								}
								var formDesignObj = options.formDesign[i];
								var sql = "select * from (" + options.formDesign[i].controlProperty.select.dataSource +
									")t";
								if (valueList) {
									sql += " where " + options.formDesign[i].controlProperty.select.hiddenValue + " in (" +
										valueList + ") ";
									vm.dealSelectDatasourceByTree(sql, formDesignObj);
								} else {
									vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");
									vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", []);
									//vm.formDesign[i].controls[j].controlProperty.select["sqlDataSource"] = [];
									vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", []);
									vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = ''
								}
							}
						}
					}
					// if (options.formDesign[i].baseProperty.controlType == "fileUpload") {
					// 	console.log(vm.formData[options.formDesign[i].baseProperty.controlName]);
					// 	vm.formData[options.formDesign[i].baseProperty.controlName + '_files'] = vm.uploaderImg(vm
					// 		.formData[options.formDesign[i].baseProperty.controlName]);
					// 	console.log(JSON.stringify(vm.formData))
					// }
				}

				if (that.origin == 'draft') { // 来源-草稿箱
					if (!vm.isUpdate) {

						let columns = vm.columns;
						let selections = that.$store.state.MenuDetail.dataInfo.childListData;
						let childFormDatas = [];

						console.log(columns);
						console.log(selections);

						vm.childFormList.forEach(item => {
							item['columns'] = columns;
							// item['tableData'] = selections;

							childFormDatas.push({
								name: item.title,
								frameName: item.name,
								record: selections
							});
						});
						console.log(childFormDatas);


						setTimeout(() => {
							//插入子表数据
							childFormDatas.forEach(item => {
								if (item.record.length && JSON.stringify(item) !=
									'{}') {
									//插入子表
									vm.insertImportData(item.frameName, item
										.record);
								}
							});
						}, 300)

					}


				} else {

					// 加载完成，触发
					if (!vm.$utils.isEmpty(vm.onReadyCallBack) && !vm.isUpdate) {
						// let scripts = vm.onReadyCallBack.replace(/\["/g, "vm.formData[\"");
						// console.log(scripts)

						setTimeout(() => {

							console.log(vm.onReadyCallBack)
							that.$nextTick(() => {
								eval(vm.onReadyCallBack);
							})
						}, 500)
					}
				}

				console.log(vm.formData)
				console.log(options.formDesign)
				vm.formDesign = options.formDesign;
				// vm.link();
			},
			//处理扫描结果
			dealScan(scanData) {
				if (vm.scanConfig) {
					var script = vm.scanConfig.replace(/\['/g, "vm.formData['");
					script = script.replace(/\["/g, "vm.formData[\"");
					eval(script);
				}
			},
			//处理下拉数据源显示字符串
			dealSelectDatasource(sql, formDesignObj) {
				vm.Request.requestByUrl("/SQLData/GetDataBySql", {
					sql: sql
				}, function(data) {
					vm.$set(formDesignObj.controlProperty.select, "sqlDataSource", data.ds);
					vm.$set(formDesignObj.controlProperty.select, "originDataSource", data.ds);

					//判断隐藏值类型和当前赋值类型是否一致
					if (data.ds.length > 0 && (vm.formData[formDesignObj.baseProperty.controlName] != undefined &&
							vm.formData[formDesignObj.baseProperty.controlName] != null)) {
						var dataType = typeof(data.ds[0][formDesignObj.controlProperty.select.hiddenValue]);
						if (dataType != typeof(vm.formData[formDesignObj.baseProperty.controlName])) {
							if (dataType == "int" || dataType == "number") {
								vm.formData[formDesignObj.baseProperty.controlName] = parseInt(vm.formData[
									formDesignObj.baseProperty.controlName]);
							} else if (dataType == "boolean") {
								vm.formData[formDesignObj.baseProperty.controlName] = Boolean(parseInt(vm.formData[
									formDesignObj.baseProperty.controlName]));
							}
						} else {
							vm.formData[formDesignObj.baseProperty.controlName] = vm.formData[formDesignObj
								.baseProperty.controlName];
						}
						vm.formData[formDesignObj.baseProperty.controlName + '_show'] = ''

						var curDs = data.ds.filter(function(item) {
							return item[formDesignObj.controlProperty.select.hiddenValue] == vm.formData[
								formDesignObj.baseProperty.controlName]
						});
						if (curDs.length > 0) {
							vm.formData[formDesignObj.baseProperty.controlName + '_show'] = curDs[0][formDesignObj
								.controlProperty.select.displayValue
							]
						}
					}
				})
			},
			dealSelectDatasourceByTree(sql, formDesignObj) {
				vm.Request.requestByUrl("/SQLData/GetDataBySql", {
					sql: sql,
					sqlParam: vm.formData
				}, function(data) {
					//options.formDesign[i].controlProperty.select["sqlDataSource"] = data.data.ds;
					//options.formDesign[i].controlProperty.select["originDataSource"] = data.data.ds;
					vm.$set(formDesignObj.controlProperty.select, "sqlDataSource", data.ds);
					vm.$set(formDesignObj.controlProperty.select, "originDataSource", data.ds);
					//绑定固定值
					vm.$set(formDesignObj.controlProperty.select, "actualName", "");
					//options.formDesign[i].controlProperty.select["actualName"] = "";
					var actualList = data.ds.filter(function(item) {
						return item[formDesignObj.controlProperty.select.hiddenValue] == vm.formData[
							formDesignObj.baseProperty.controlName]
					});
					vm.formData[formDesignObj.baseProperty.controlName + '_show'] = ''
					if (actualList.length > 0) {
						var displayValue = actualList.map(function(item) {
							return item[formDesignObj.controlProperty.select.displayValue]
						}).join(',');
						vm.$set(formDesignObj.controlProperty.select, "actualName", displayValue);
						//options.formDesign[i].controlProperty.select["actualName"] = actualList[0][options.formDesign[i].controlProperty.select.displayValue];
						vm.formData[formDesignObj.baseProperty.controlName + '_show'] = displayValue;
					} else {
						vm.formData[formDesignObj.baseProperty.controlName + '_show'] = '';
					}
				})
			},
			childPageInit(childObj) {
				var that = this;
				that.Request.requestByUrl('/AppFormList/GetDataByName', {
					objName: childObj.name
				}, function(data) {
					console.log(data)
					var filterCondition = data.ds[0]["filterCondition"];
					if (filterCondition == null) {
						filterCondition = "";
					}
					vm.childTableConfig({
						childObj: childObj,
						columns: JSON.parse(data.ds[0]["columnsConfig"]),
						workList: JSON.parse(data.ds[0]["worksConfig"]),
						crudList: JSON.parse(data.ds[0]["crudConfig"]),
						params: {
							isFormList: data.ds[0]["isFormList"],
							physicalTableName: data.ds[0]["physicalTableName"],
							isPaging: data.ds[0]["isPaging"],
							filterCondition: filterCondition,
							defaultOrder: data.ds[0]["defaultOrder"],
							detailName: data.ds[0]["detailName"],
							isFormEdit: false,
							rowClassCol: data.ds[0]["rowClassCol"],
							onReadyCallBack: data.ds[0]["onReadyCallBack"],
							colClassCol: data.ds[0]["colClassCol"],

						}
					})
				});
			},
			childTableConfig(options) {
				var that = this;
				options.childObj["tableData"] = [];
				options.childObj["params"] = options.params;
				options.childObj["workList"] = options.workList;
				options.childObj["crudList"] = options.crudList;
				options.childObj["columns"] = options.columns;
				that.columns = options.columns;

				that.childObj = that.$utils.deepClone(options.childObj);

				var filterCondition = '1=1';
				if (options.params.filterCondition) {
					filterCondition += ' and ' + options.params.filterCondition;
				}
				let connectParams = vm.formData[options.childObj['connectParams']];
				if (!connectParams) {
					filterCondition += " and 1=0 ";
				} else {
					filterCondition += " and " + options.childObj['connectParams'] + "='" + connectParams + "'";
				}

				var titleCols = options.childObj.columns.filter(function(item) {
					return item.isTitle == true
				});
				if (titleCols.length > 0) {
					options.childObj["titleCol"] = titleCols[0];
				}

				vm.Request.requestByUrl('/SQLData/GetDataByPhysicalTableNameByQueryPaging_Uniapp', {
					tableName: options.params.physicalTableName,
					columnsStr: JSON.stringify([]),
					currentCol: '',
					pageIndex: 1,
					pageSize: 9999,
					isForm: (options.params.isFormList || true).toString(),
					filterCondition: filterCondition,
					defaultOrder: options.params.defaultOrder || ''
				}, function(data) {
					var tableData = data.ds;
					console.log(tableData);
					//vm.$set(curChildObj, "tableData", data.ds);
					// 低配置设备导入数据，可能会因为这个tableData，导致数据被刷掉
					// 判断来源
					if (that.origin != 'draft' || vm.isUpdate) { // 非草稿箱
						options.childObj["tableData"] = data.ds;
					}
					vm.refreshChildCol(options.childObj);
					vm.$forceUpdate();
					// //}
					// // if (curChildObj.pageIndex == 1) {

					// // } else {
					// //     curChildObj.tableData = curChildObj.tableData.concat(data.ds);
					// // }

					// for (var i = 0; i < curChildObj.tableData.length; i++) {
					// 	curChildObj.tableData[i].objNo = (i + 1).toString();
					// 	if (!curChildObj.tableData[i].guid) {
					// 		curChildObj.tableData[i].guid = vm.guid();
					// 	}
					// }
					// if (data.ds1.length > 0) {
					// 	//绑定总长度
					// 	if (curChildObj.tableData.length >= parseInt(data.ds1[0]["@TotalCount"])) {
					// 		curChildObj.finished = true;
					// 	}
					// }
					// curChildObj.pageIndex = curChildObj.pageIndex + 1;
					// // for(var i=0;i<tableData.length;i++){
					// //   tableData[i].objNo = (i+1).toString();
					// // }
					// //
					// // vm.$set(curChildObj, "tableData",tableData );
					// vm.refreshChildCol(curChildObj);
					// vm.calSummaryData(curChildObj);

				}, function() {
					vm.tableData = [];
				});
			},
			refreshChildCol(childObj) {
				for (var i = 0; i < childObj.columns.length; i++) {
					//下拉框数据加载
					if (childObj.columns[i].colType == 2 && childObj.columns[i].selDetail.type < 3) {
						var sql = childObj.columns[i].selDetail.dataSource;
						var selDetailObj = childObj.columns[i].selDetail;
						vm.changeDataAjax(sql, "1=1", function(data, requestObj) {
							requestObj.sqlDataSource = data;
							vm.$forceUpdate();
						}, selDetailObj);
					} else if (childObj.columns[i].colType == 2 && childObj.columns[i].selDetail.type == 3) {
						var valueList = [];
						for (var j = 0; j < childObj.tableData.length; j++) {
							//if (vm.tableData[j][vm.columns[i].selDetail.hiddenValue] != null && vm.tableData[j][vm.columns[i].selDetail.hiddenValue] != undefined && vm.tableData[j][vm.columns[i].selDetail.hiddenValue] != '') {
							//    valueList.push("'" + vm.tableData[j][vm.columns[i].selDetail.hiddenValue] + "'");
							//}
							if (childObj.tableData[j][childObj.columns[i].colName]) {
								for (var k = 0; k < childObj.tableData[j][childObj.columns[i].colName].toString().split(
										',').length; k++) {
									valueList.push("'" + childObj.tableData[j][childObj.columns[i].colName].toString()
										.split(',')[k] + "'");
								}
							}
						}
						//var sql = "select * from (" + vm.columns[i].selDetail.dataSource + ")t";
						if (valueList.length > 0) {
							var selDetailObj = childObj.columns[i].selDetail;
							vm.changeDataAjax(childObj.columns[i].selDetail.dataSource, childObj.columns[i]
								.selDetail.hiddenValue + " in (" + valueList.join(',') + ") ",
								function(data, requestObj) {
									requestObj.sqlDataSource = data;
									vm.$forceUpdate();
								}, selDetailObj);
						} else {
							childObj.columns[i].selDetail.sqlDataSource = [];
						}
					}
				}
				vm.initGlobalTable(childObj);
				//vm.calSummary(childObj);
				vm.$forceUpdate();
			},
			refreshEditValueCol(childObj) {
				for (var i = 0; i < childObj.columns.length; i++) {
					//下拉框数据加载
					if (childObj.columns[i].colType == 2 && childObj.columns[i].selDetail.type < 3) {
						var sql = childObj.columns[i].selDetail.dataSource;
						var selDetailObj = childObj.columns[i].selDetail;
						console.log(sql)
						vm.changeDataAjax(sql, "1=1", function(data, requestObj) {
							console.log(data)

							requestObj.sqlDataSource = data;
							vm.$forceUpdate();
						}, selDetailObj);
					} else if (childObj.columns[i].colType == 2 && childObj.columns[i].selDetail.type == 3) {
						var valueList = [];
						if (vm.editValues[childObj.columns[i].colName]) {
							for (var k = 0; k < vm.editValues[childObj.columns[i].colName].toString().split(
									',').length; k++) {
								valueList.push("'" + vm.editValues[childObj.columns[i].colName].toString()
									.split(',')[k] + "'");
							}
						}
						//加上原有表格内的当前数据集合
						childObj.tableData.forEach(function(tItem) {
							if (tItem[childObj.columns[i].colName] != null && tItem[childObj.columns[i].colName] !=
								undefined && tItem[childObj.columns[i].colName] != 'undefined' && tItem[childObj
									.columns[i].colName] != 'null') {
								for (var k = 0; k < (tItem[childObj.columns[i].colName].toString()).split(',')
									.length; k++) {
									valueList.push("'" + (tItem[childObj.columns[i].colName].toString()).split(
										',')[k] + "'");
								}
							}
						});

						//var sql = "select * from (" + vm.columns[i].selDetail.dataSource + ")t";
						console.log(valueList)
						if (valueList.length > 0) {
							var selDetailObj = childObj.columns[i].selDetail;
							vm.changeDataAjax(childObj.columns[i].selDetail.dataSource, childObj.columns[i]
								.selDetail.hiddenValue + " in (" + valueList.join(',') + ") ",
								function(data, requestObj) {
									//var sql = "select * from (" + vm.columns[i].selDetail.dataSource + ")t";
									console.log(data)
									requestObj.sqlDataSource = data;
									vm.$forceUpdate();
								}, selDetailObj);
						} else {
							childObj.columns[i].selDetail.sqlDataSource = [];
						}
					}
				}
				//vm.calSummary(childObj);
				vm.$forceUpdate();
			},
			//显示下拉数据源中的真实数据
			showActualValue(value, colObject, originValue) {
				if (colObject.selDetail.sqlDataSource) {
					var curObject = colObject.selDetail.sqlDataSource.filter(function(item) {
						return item[colObject.selDetail.hiddenValue] == value
					});
					if (curObject.length > 0) {
						return curObject[0][colObject.selDetail.displayValue];
					} else if (originValue) {
						return originValue;
					} else {
						return '';
					}
				} else {
					return '';
				}
				//return '';
			},
			initGlobalTable(childObj, disChange, isCallBack) {
				//添加objNo
				for (var i = 0; i < childObj.tableData.length; i++) {
					childObj.tableData[i].objNo = (i + 1).toString();
					childObj.tableData[i].colInfo = childObj.columns;
					if (!childObj.tableData[i].guid) {
						childObj.tableData[i].guid = vm.guid();
					}


					if (!disChange) {
						for (var j = 0; j < childObj.columns.length; j++) {
							if (childObj.columns[j].colChange) {
								vm.handlerControlChange(i, childObj.columns[j].colChange);
							}
						}
					}
					if (isCallBack) {
						for (var j = 0; j < childObj.columns.length; j++) {
							if (childObj.columns[j].colCallBack) {
								vm.handlerControlChange(i, childObj.columns[j].colCallBack);
							}
						}
					}
				}
			},
			handlerControlChange() {

			},
			getformDataFile(formCol) {
				var that = this;
				var fileData = that.formData[formCol.baseProperty.controlName];
				var fileList = [];
				if (fileData) {
					fileData.split(',').forEach(function(filePath) {
						if (filePath) {
							fileList.push({
								url: vm.Request.IPAgreement() + vm.Request.serverIP() + filePath
							});
						}
					});
				}
				return fileList;
			},
			beforeReadHandler(file, fObj) {
				var fileControl = vm.formDesign.filter(function(item) {
					return item.baseProperty.controlName == fObj.name;
				});
				if (fileControl.length > 0) {
					console.log(file);
					var uploadLen = file.length;
					if (!fileControl[0].controlProperty.upload.isMulti) {
						uploadLen = 1;
						file = [file];
						console.log(file)
					}
					for (var i = 0; i < uploadLen; i++) {
						var readyFile = file[i];
						//判断文件大小
						if (fileControl[0].controlProperty.upload.fileSize !== "" && fileControl[0].controlProperty.upload
							.fileSize != "0") {
							var maxSize = parseInt(fileControl[0].controlProperty.upload.fileSize);
							if (readyFile.size > maxSize) {
								uni.showToast({
									title: "请上传小于" + maxSize + "字节长度的文件",
									icon: 'none'
								});
							}
						}
						//判断文件类型
						else if (fileControl[0].controlProperty.upload.fileType !== "") {
							var fileType = fileControl[0].controlProperty.upload.fileType.toLowerCase();
							var isMatch = false;
							for (var i = 0; i < fileType.split(',').length; i++) {
								if (readyFile.url.toLowerCase().indexOf(fileType.split(',')[i]) >= 0) {
									isMatch = true;
								}
							}
							if (!isMatch) {
								uni.showToast({
									title: "请上传" + fileType + "类型的文件",
									icon: 'none'
								});
							}
						}
						//上传
						else {
							uni.uploadFile({
								url: vm.Request.IPAgreement() + vm.Request.serverIP() +
									'/FileData/UploadSignleFile',
								filePath: readyFile.url,
								name: 'file',
								formData: fileControl[0].controlProperty.upload,
								success: (uploadFileRes) => {
									uploadFileRes.data = JSON.parse(uploadFileRes.data);
									if (uploadFileRes.data.status == 200) {
										//是否多图上传
										if (fileControl[0].controlProperty.upload.isMulti) {
											if (vm.formData[fileControl[0].baseProperty.controlName]) {
												var formList = vm.formData[fileControl[0].baseProperty
													.controlName].split(',');
												formList.push(uploadFileRes.data.data);
												vm.formData[fileControl[0].baseProperty.controlName] = formList
													.join(',');
											} else {
												vm.formData[fileControl[0].baseProperty.controlName] =
													uploadFileRes.data.data;
											}
										} else {
											vm.formData[fileControl[0].baseProperty.controlName] =
												uploadFileRes.data.data;
										}
										vm.$forceUpdate();
									}
								},
								fail: (error) => {
									console.log(error);
								}
							});
						}
					}

				}
			},
			//删除数据
			deleteUploadFile(event) {
				console.log(event);
				var fileControl = vm.formDesign.filter(function(item) {
					return item.baseProperty.controlName == event.name;
				});
				if (fileControl.length > 0) {
					if (!fileControl[0].controlProperty.upload.isMulti) {
						vm.formData[fileControl[0].baseProperty.controlName] = '';
					} else {
						var fileNames = vm.formData[fileControl[0].baseProperty.controlName].split(',');
						var newFileNames = [];
						fileNames.forEach(function(item) {
							if (event.file.url.indexOf(item) < 0) {
								newFileNames.push(item);
							}
						});
						vm.formData[fileControl[0].baseProperty.controlName] = newFileNames.join(',');
					}
				}
			},
			formatterDate(value, format) {
				var that = this;
				if (value) {
					var originDate = value.split(' ')[0].split('T')[0];
					if (!format) {
						format = "yyyy-MM-dd";
					}
					//根据传入的格式化字符串，进行格式化
					return that.Request.dateFormat(originDate, format);
				} else {
					return value;
				}
			},
			openBaseScreen(row) {
				vm.windowSelectType = 1;
				vm.curSelectWindowObj = row;
				if (row.baseProperty.isReadOnly) {
					return false;
				} else {
					var obj = {
						chooseType: row.controlProperty.select.chooseType,
						allowClear: true,
						showSearch: true,
						searchKey: row.controlProperty.select.displayValue,
						serverSearch: true,
						displayValue: row.controlProperty.select.displayValue,
						hiddenValue: row.controlProperty.select.hiddenValue,
						parentValue: row.controlProperty.select.parentValue,
						isPaging: true,
						sql: row.controlProperty.select.dataSource,
						name: row.baseProperty.labelName,
						colName: row.baseProperty.controlName,
						param: {},
						treeObj: {
							treeDataSource: row.controlProperty.select.treeDataSource,
							treeDisplayValue: row.controlProperty.select.treeDisplayValue,
							treeHiddenValue: row.controlProperty.select.treeHiddenValue,
							treeParentValues: row.controlProperty.select.treeParentValues,
						}
					}
					obj.param = JSON.parse(JSON.stringify(vm.formData));
					obj.param[row.controlProperty.select.displayValue] = "";

					vm.$store.commit('ChangeAndSetStateData', {
						Name1: 'SelectPickerSetting',
						data: obj
					});

					uni.navigateTo({
						// url: '/commonPage/Tool/selectPicker'
						url: '/commonPage/Tool/selectPicker' + '?pickerListen=selectPicker_formEdit'
					})
				}
			},
			openBaseScreen2(row) {
				vm.windowSelectType = 2;
				vm.curSelectWindowObj2 = row;
				if (row.isReadOnly) {
					return false;
				} else {
					var obj = {
						chooseType: row.selDetail.chooseType,
						allowClear: true,
						showSearch: true,
						searchKey: row.selDetail.displayValue,
						serverSearch: true,
						displayValue: row.selDetail.displayValue,
						hiddenValue: row.selDetail.hiddenValue,
						parentValue: row.selDetail.parentValue,
						isPaging: true,
						sql: row.selDetail.dataSource,
						name: row.colDesc,
						colName: row.colName,
						param: {},
						treeObj: {
							treeDataSource: row.selDetail.treeDataSource,
							treeDisplayValue: row.selDetail.treeDisplayValue,
							treeHiddenValue: row.selDetail.treeHiddenValue,
							treeParentValues: row.selDetail.treeParentValues,
						},
						filterSQL: row.selDetail.filterSQL,
						formSQL: row.selDetail.formSQL
					}
					obj.param = JSON.parse(JSON.stringify(vm.editValues));
					obj.param.colInfo = "";
					obj.param[row.selDetail.displayValue] = "";

					vm.$store.commit('ChangeAndSetStateData', {
						Name1: 'SelectPickerSetting',
						data: obj
					});

					uni.navigateTo({
						url: '/commonPage/Tool/selectPicker' + '?pickerListen=selectPicker_formEdit'
					})
				}
			},
			//时间组件
			clickDatePicker(row) {
				if (row.baseProperty.isReadOnly) {
					return false;
				} else {
					vm.curDateObj = row;


					let theDate = new Date();
					if (!this.$utils.isEmpty(vm.formData[row.baseProperty.controlName])) {
						theDate = new Date(vm.formData[row.baseProperty.controlName]);
					}
					let dateDown = vm.Request.dateFormat(theDate, 'Y-MM-dd');
					vm.curDate = dateDown
					// vm.curDate = new Date(vm.formatterDate(vm.formData[row.baseProperty.controlName]));
					vm.showDatePicker = true;
				}
			},
			clickDatePicker2(row) {
				if (row.isReadOnly) {
					return false;
				} else {
					// vm.curDateObj2 = row;
					// console.log(vm.editValues[row.colName])
					// let theDate = new Date();
					// if (!this.$utils.isEmpty(vm.editValues[row.colName])) {
					// 	theDate = new Date(vm.formatterDate(vm.editValues[row.colName]));
					// }
					// console.log(theDate)
					// vm.curDate2 = theDate;
					// vm.showDatePicker2 = true;

					vm.curDateObj2 = row;
					let theDate = new Date();
					if (!this.$utils.isEmpty(vm.editValues[row.colName])) {
						theDate = new Date(vm.editValues[row.colName]);
					}
					let dateDown = vm.Request.dateFormat(theDate, 'Y-MM-dd');
					console.log(dateDown)
					vm.curDate2 = dateDown;
					vm.showDatePicker2 = true;
				}
			},
			onDatePickerConfirm(value) {
				value = value.value + '';
				if (value && !isNaN(Number(value))) {
					let dateDown = vm.Request.dateFormat(new Date(Number(value)), 'Y-MM-dd');
					vm.formData[vm.curDateObj.baseProperty.controlName] = dateDown;
					// vm.formData[vm.curDateObj.baseProperty.controlName] = vm.Request.getRealDate(value).split(' ')[0];
				} else if (!value) {
					vm.formData[vm.curDateObj.baseProperty.controlName] = "";
				}
				vm.dataChange(vm.curDateObj);
				vm.showDatePicker = false;
				vm.curDateObj = '';
				vm.curDate = '';
			},
			onDatePickerConfirm2(value) {
				value = value.value + '';
				if (value && !isNaN(Number(value))) {
					let dateDown = vm.Request.dateFormat(new Date(Number(value)), 'Y-MM-dd');
					vm.editValues[vm.curDateObj2.colName] = dateDown;
					// vm.editValues[vm.curDateObj2.colName] = vm.Request.getRealDate(value).split(' ')[0];
				} else if (!value) {
					vm.editValues[vm.curDateObj2.colName] = "";
				}
				//vm.tableDataChange(vm.curDateObj2);
				vm.showDatePicker2 = false;
				vm.curDateObj2 = '';
				vm.curDat2 = '';
			},
			//传递参数，默认值
			transParamsDefault() {
				for (var i = 0; i < vm.childFormList.length; i++) {
					var defaultParams = vm.childFormList[i].defaultParams.split(',');
					var defaultChildParams = vm.childFormList[i].defaultChildParams.split(',');
					for (var j = 0; j < defaultParams.length; j++) {
						vm.childFormList[i].fixedValues[defaultChildParams[j]] = vm.formData[defaultParams[j]];
					}
					var transParams = vm.childFormList[i].transParams.split(',');
					var transChildParams = vm.childFormList[i].transChildParams.split(',');
					for (var j = 0; j < transParams.length; j++) {
						vm.childFormList[i].fixedValues[transChildParams[j]] = vm.formData[transParams[j]];
						vm.childFormList[i].tableData.forEach(function(tItem) {
							tItem[transChildParams[j]] = vm.formData[transParams[j]];
						});
					}
					vm.$forceUpdate();
				}
			},
			link() {
				//查询关联单据
				// 			var objName = $("#keyName").val();
				// 			var objValue = $("#keyValue").val();
				// 			vm.post("select * from paramlink where paramName=@paramName order by sort asc ", {
				// 				paramName: objName
				// 			}, function (data) {
				// 				vm.objDetailModelList = [];
				// 				for (var i = 0; i < F.ui.contextMenuTab.items.length; i++) {
				// 					F.ui.contextMenuTab.removeTab(i);
				// 				}
				// 				for (var i = 0; i < data.ds.length; i++) {
				// 					if (data.ds[i].tabType == 1) {
				// 						var searchKeyName = data.ds[i].keyName;
				// 						var searchKeyValue = 0;
				// 						//查询主键值
				// 						vm.post("select * from " + data.ds[i].tableName + " where " + objName + "='" + objValue + "'  ", {}, function (ret) {
				// 							if (ret.ds.length > 0) {
				// 								var src = data.ds[i].src + "&keyName=" + searchKeyName + "&keyValue=" + ret.ds[0][searchKeyName] + "&isView=1";
				// 								//data.ds[i].src = src;
				// 								//parent.vm.objDetailModelList.push(data.ds[i]);
				// 								var isActive = false;
				// 								if (i == 0) {
				// 									isActive = true;
				// 								}
				// 								//添加页签
				// 								F.ui.contextMenuTab.addTab({
				// 									title: data.ds[i].title,
				// 									iframe: true,
				// 									iframeUrl: src
				// 								}, false, isActive);
				// 							}
				// 						});
				// 					}
				// 					else if (data.ds[i].tabType == 2) {
				// 						var query = objName + "='" + objValue + "'";
				// 						let base64Helper = Base64;
				// 						query = base64Helper.encode(query)
				// 						var src = data.ds[i].src + "&query=" + query + "&isView=1";
				// 						//data.ds[i].src = src;
				// 						//parent.vm.objDetailModelList.push(data.ds[i]);
				// 						var isActive = false;
				// 						if (i == 0) {
				// 							isActive = true;
				// 						}
				// 						//添加页签
				// 						F.ui.contextMenuTab.addTab({
				// 							title: data.ds[i].title,
				// 							iframe: true,
				// 							iframeUrl: src
				// 						}, false, isActive);
				// 					}
				// 					else if (data.ds[i].tabType == 3) {
				// 						var src = data.ds[i].src + "&" + objName + "=" + objValue;
				// 						var isActive = false;
				// 						if (i == 0) {
				// 							isActive = true;
				// 						}
				// 						//添加页签
				// 						F.ui.contextMenuTab.addTab({
				// 							title: data.ds[i].title,
				// 							iframe: true,
				// 							iframeUrl: src
				// 						}, false, isActive);



				// 					}
				// 				}
				// 			});
				// 			F.ui.windowContextMenu.show();
				// 			F.ui.windowContextMenu.maximize();
				// 			F.ui.windowContextMenu.setTitle(vm.showDetailTitle);

			},
			//计算汇总数据
			calSummary(childObj) {
				var totalFunctions = childObj.columns.filter(function(item) {
					return item.colTotalFunction;
				});
				childObj["totalFunctions"] = totalFunctions;
				totalFunctions.forEach(function(item) {
					if (item.colTotalFunction == "sum") {
						//保留位数
						var fixNum = 2;
						var totalNum = 0;
						for (var j = 0; j < childObj.tableData.length; j++) {
							var currentNum = parseFloat(childObj.tableData[j][item.colName]);
							if (isNaN(currentNum)) {
								currentNum = 0;
							}
							totalNum += currentNum;
						}
						item["summaryData"] = totalNum.toFixed(fixNum);
					}
				});
				vm.$forceUpdate();
			},
			showChildFormTableDataLen(tableData) {
				//console.log(tableData.length)
				// return tableData.length.toString();
				var that = this;
				if (that.childFormList.length > 0 && that.childFormList[0].tableData) {
					return that.childFormList[0].tableData.length;
				} else {
					return '';
				}
			},
			//导入数据
			importData(config) {
				if (config.js) {
					var script = config.js.replace(/\['/g, "vm.formData['");
					script = script.replace(/\["/g, "vm.formData[\"");
					eval(script);
				} else {
					vm.importEvent(config);
				}
			},
			importEvent: function(config) {
				var obj = {
					formDesign: config.reportDesignConfig,
					sql: config.sql,
					importJs: config.importJs,
					columns: config.columns,
					originFormData: vm.formData,
					name: config.btnName,
				}

				// console.log(config.columns)

				vm.$store.commit('ChangeAndSetStateData', {
					Name1: 'ImportPickerSetting',
					data: obj
				});
				uni.navigateTo({
					url: '/commonPage/Tool/importPicker'
				})
			},
			//插入子表数据
			insertImportData(childName, importData) {
				let that = this;
				let selectChildren = vm.childFormList.filter(function(item) {
					return item.name == childName
				});
				// console.log(selectChildren[0])
				console.log(selectChildren)
				if (selectChildren.length > 0) {
					console.log(importData.length)

					importData.forEach(item => {
						var importObj = Object.assign(JSON.parse(JSON.stringify(selectChildren[0].fixedValues)),
							item);

						var connectParams = selectChildren[0].connectParams;
						if (vm.formData[connectParams]) {
							importObj[connectParams] = vm.formData[connectParams];
						}

						if (!('tableData' in selectChildren[0])) {
							selectChildren[0]['tableData'] = [];
						}
						console.log(importObj)

						selectChildren[0]['tableData'].push(importObj);
						selectChildren[0].crud.create.push(importObj);
						console.log(selectChildren[0])

					})

					// for (var i = 0; i < importData.length; i++) {
					// 	//合并对象
					// 	var importObj = Object.assign(JSON.parse(JSON.stringify(selectChildren[0].fixedValues)),
					// 		importData[i]);

					// 	var connectParams = selectChildren[0].connectParams;
					// 	if (vm.formData[connectParams]) {
					// 		importObj[connectParams] = vm.formData[connectParams];
					// 	}
					// 	if (!('tableData' in selectChildren[0])) {
					// 		selectChildren[0]['tableData'] = [];
					// 	}

					// 	selectChildren[0]['tableData'].push(importObj);
					// 	selectChildren[0].crud.create.push(importObj);
					// 	console.log(selectChildren[0])
					// }
					console.log(this.columns)

					if (this.$utils.isEmpty(selectChildren[0]['columns'])) {
						selectChildren[0]['columns'] = this.columns
					}
					console.log(vm.formData)

					vm.refreshChildCol(selectChildren[0]);
					vm.initGlobalTable(selectChildren[0]);
					vm.$forceUpdate();
				}
			},
			//更新行
			updateRow(modifyRecord) {
				//不存在在新增中
				if (vm.editFrame.crud.create.filter(function(item) {
						return item.guid == modifyRecord.guid
					}).length == 0) {
					//同时也不存在在更新中
					if (vm.editFrame.crud.update.filter(function(item) {
							return item.guid == modifyRecord.guid
						}).length == 0) {
						vm.editFrame.crud.update.push(modifyRecord)
					} else {
						for (var i = 0; i < vm.editFrame.crud.update.length; i++) {
							if (vm.editFrame.crud.update[i].guid == modifyRecord.guid) {
								vm.editFrame.crud.update[i] = modifyRecord;
							}
						}
					}
				} else {
					for (var i = 0; i < vm.editFrame.crud.create.length; i++) {
						if (vm.editFrame.crud.create[i].guid == modifyRecord.guid) {
							vm.editFrame.crud.create[i] = modifyRecord;
						}
					}
				}
			},
			delRow(childForm, delRecord) {
				uni.showModal({
					title: '提示',
					content: '是否删除此行？',
					success: function(res) {
						if (res.confirm) {
							//不存在在新增中
							if (childForm.crud.create.filter(function(item) {
									return item.guid == delRecord.guid
								}).length == 0 && childForm.crud.update.filter(function(item) {
									return item.guid == delRecord.guid
								}).length == 0) {
								childForm.crud.delete.push(delRecord);
							}
							//存在在更新中
							else if (childForm.crud.update.filter(function(item) {
									return item.guid == delRecord.guid
								}).length > 0) {
								childForm.crud.update = childForm.crud.update.filter(function(item) {
									return item.guid != delRecord.guid
								});
								childForm.crud.delete.push(delRecord);
							} else if (childForm.crud.create.filter(function(item) {
									return item.guid == delRecord.guid
								}).length > 0) {
								childForm.crud.create = childForm.crud.create.filter(function(item) {
									return item.guid != delRecord.guid
								});
							}
							//删除表格里的数据
							childForm.tableData = childForm.tableData.filter(function(item) {
								return item.guid != delRecord.guid;
							});
							for (var i = 0; i < childForm.tableData.length; i++) {
								childForm.tableData[i].objNo = (i + 1).toString();
								if (!childForm.tableData[i].guid) {
									childForm.tableData[i].guid = vm.guid();
								}
							}
							vm.$refs.delSwiper.forEach(item => item.closeHandler(true))
							vm.$forceUpdate();
						} else if (res.cancel) {}
					}
				});
			},
			//按钮显示条件判断
			btn_showCondition(type, btn) {
				try {
					var _this = this;
					var result = true;
					var showScript = "";
					//普通crud
					if (type == 1) {
						if (btn == "新增") {
							showScript = _this.crudList[0].show;
						} else if (btn == "编辑") {
							showScript = _this.crudList[1].show;
						} else if (btn == "删除") {
							showScript = _this.crudList[2].show;
						}
					}
					//业务按钮
					else if (type == 2) {
						showScript = btn.show;
					}
					//调入按钮
					else if (type == 3) {
						showScript = btn.btnShow;
					}
					if (showScript) {
						var script = showScript.replace(/\['/g, "_this.formData['");
						script = script.replace(/\["/g, "_this.formData[\"");
						eval("result=(" + script + ")");
					}
					return result;
				} catch (e) {
					return false;
				}
			},
			//子表渲染条件
			btn_showConditionByChild(btn) {
				try {
					var _this = this;
					var result = true;
					var showScript = "";
					//业务按钮
					showScript = btn.show;
					if (showScript) {
						var script = showScript.replace(/\['/g, "_this.formData['");
						script = script.replace(/\["/g, "_this.formData[\"");
						eval("result=(" + script + ")");
					}
					return result;
				} catch (e) {
					return false;
				}
			},
			//生成GUID
			guid() {
				return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
					var r = Math.random() * 16 | 0,
						v = c == 'x' ? r : (r & 0x3 | 0x8);
					return v.toString(16);
				});
			},
			//打开编辑窗口
			openEditWin(editObj, childForm) {
				vm.editValues = editObj;
				vm.editFrame = childForm;
				vm.showEditWin = true;
			},
			closeEditWin() {
				vm.updateRow(vm.editValues);
				vm.showEditWin = false;
			},
			filterImportConfigList() {
				var that = this;
				return that.importConfig.filter(function(config) {
					return that.btn_showCondition(3, config)
				})
			},
			//主表验证必填
			valitedRequired() {
				var resultObj = {
					status: 200,
					msg: ""
				};
				for (var i = 0; i < vm.formDesign.length; i++) {
					if (vm.formDesign[i].baseProperty.isRequired) {
						if (vm.formData[vm.formDesign[i].baseProperty.controlName] === "" || vm.formData[vm.formDesign[i]
								.baseProperty.controlName] === null) {
							resultObj = {
								status: 500,
								msg: vm.formDesign[i].baseProperty.labelName + "字段不能为空!"
							};
						}
					}
				}
				return resultObj;
			},
			//验证子表必填项
			valitedChildForm(childForm, createObjs, updateObjs) {
				var valited = true;
				var valitedColumn = "";
				var index = 0;
				for (var i = 0; i < childForm.columns.length; i++) {
					if (childForm.columns[i].isRequired) {
						for (var j = 0; j < createObjs.length; j++) {
							if (createObjs[j][childForm.columns[i].colName] === undefined || createObjs[j][childForm
									.columns[i].colName
								] === null || createObjs[j][childForm.columns[i].colName] === "") {
								index = j;
								valited = false;
								valitedColumn = childForm.columns[i].colDesc;
							}
						}
						for (var j = 0; j < updateObjs.length; j++) {
							if (updateObjs[j][childForm.columns[i].colName] === undefined || updateObjs[j][childForm
									.columns[i].colName
								] === null || updateObjs[j][childForm.columns[i].colName] === "") {
								index = j;
								valited = false;
								valitedColumn = childForm.columns[i].colDesc;
							}
						}
					}
				}
				// for (var j = 0; j < createObjs.length; j++) {
				// 	if (!createObjs[j].objNo) {
				// 		index = j;
				// 		valited = false;
				// 		valitedColumn = "数据行";
				// 	}
				// }
				// for (var j = 0; j < updateObjs.length; j++) {
				// 	if (!updateObjs[j].objNo) {
				// 		index = j;
				// 		valited = false;
				// 		valitedColumn = "数据行";
				// 	}
				// }


				return {
					valited: valited,
					valitedColumn: valitedColumn,
					index: index
				};
			},
			//保存事件
			saveRow(callBackEvent, isCancelSubmit) {
				if (!vm.enabledSubmitBtn && !isCancelSubmit) {
					return;
				} else {
					vm.enabledSubmitBtn = false;
					setTimeout(function() {
						//新增操作
						if (!vm.isUpdate) {
							//带有Js脚本的，则先执行脚本
							if (vm.crudList[0].script) {
								eval(vm.crudList[0].script);
							}

							//验证必填项
							var valitedResult = vm.valitedRequired();
							if (valitedResult.status == 500) {
								uni.showToast({
									title: valitedResult.msg,
									icon: 'error'
								});
								vm.enabledSubmitBtn = true;
								return;
							} else {
								var postData = Object.assign({
									tableName: vm.physicalTableName,
									createWorkSQL: vm.crudList[0].sql
								}, vm.formData);


								vm.Request.requestByUrl("/SQLData/InsertSingleRow", postData, function(data) {
									vm.isUpdate = true;
									var keyObj = data;
									vm.keyName = keyObj.keyName;
									vm.keyValue = keyObj.keyValue;
									vm.formData[vm.keyName] = vm.keyValue;
									if (data.dataTable.length > 0) {
										vm.formData = Object.assign(vm.formData, data.dataTable[0]);
										console.log(vm.formData);
										vm.$forceUpdate();
									}

									//同步外键值
									for (var i = 0; i < vm.childFormList.length; i++) {
										var connectParams = vm.childFormList[i].connectParams;
										for (var j = 0; j < vm.childFormList[i].tableData.length; j++) {
											vm.childFormList[i].tableData[j][connectParams] = vm.formData[
												connectParams];
										}
										for (var j = 0; j < vm.childFormList[i].crud.create.length; j++) {
											vm.childFormList[i].crud.create[j][connectParams] = vm
												.formData[connectParams];
										}
										for (var j = 0; j < vm.childFormList[i].crud.update.length; j++) {
											vm.childFormList[i].crud.update[j][connectParams] = vm
												.formData[connectParams];
										}
										for (var j = 0; j < vm.childFormList[i].crud.delete.length; j++) {
											vm.childFormList[i].crud.delete[j][connectParams] = vm
												.formData[connectParams];
										}
									}
									//子表提交（使用同步提交,数量少的情况下提交）
									var isSuccess = true;
									var requestChildList = [];
									var errorStr = '';
									for (var i = 0; i < vm.childFormList.length; i++) {
										if (vm.childFormList[i].crud.create.length > 0 ||
											vm.childFormList[i].crud.update.length > 0 ||
											vm.childFormList[i].crud.delete.length > 0) {
											//验证必填项


											var result = vm.valitedChildForm(vm.childFormList[i], vm
												.childFormList[i].crud.create, vm.childFormList[i].crud
												.update);
											if (result.valited) {
												var createObj = JSON.parse(JSON.stringify(vm.childFormList[
													i].crud.create));
												createObj.colInfo = [];
												var updateObj = JSON.parse(JSON.stringify(vm.childFormList[
													i].crud.update));
												updateObj.colInfo = [];
												var deleteObj = JSON.parse(JSON.stringify(vm.childFormList[
													i].crud.delete));
												deleteObj.colInfo = [];

												requestChildList.push(vm.Request.PromiseRequestByUrl(
													"/FormList/SaveData_uniapp", {
														tableName: vm.childFormList[i].params
															.physicalTableName,
														createStr: JSON.stringify(createObj),
														updateStr: JSON.stringify(updateObj),
														deleteStr: JSON.stringify(deleteObj),
														createWork: vm.childFormList[i].crudList[0]
															.sql,
														updateWork: vm.childFormList[i].crudList[1]
															.sql,
														deleteWork: vm.childFormList[i].crudList[2]
															.sql
													}));
												uni.$emit('FormInitToRefresh', {
													keyID: vm.formData[vm.keyName]
												})
												// vm.Request.requestByUrl("/FormList/SaveData",{
												// 		tableName: vm.childFormList[i].params.physicalTableName,
												// 		createStr: JSON.stringify(vm.childFormList[i].crud.create),
												// 		updateStr: JSON.stringify(vm.childFormList[i].crud.update) ,
												// 		deleteStr: JSON.stringify(vm.childFormList[i].crud.delete),
												// 		createWork: vm.childFormList[i].crudList[0].sql,
												// 		updateWork: vm.childFormList[i].crudList[1].sql,
												// 		deleteWork: vm.childFormList[i].crudList[2].sql
												// 	},function(data){
												// 		if (data.status == 500) {
												// 			vm.$toast(data.msg);
												// 			isSuccess = false;
												// 		} else {
												// 			//vm.childPageInit(vm.childFormList[i]);
												// 			vm.childFormList[i].crud.create = [];
												// 			vm.childFormList[i].crud.update = [];
												// 			vm.childFormList[i].crud.delete = [];
												// 		}
												// 	})
											} else {
												errorStr += result.valitedColumn + "不能为空!";
												isSuccess = false;
											}
										}
									}
									if (!isSuccess) {
										uni.showToast({
											title: errorStr,
											icon: 'error'
										});
										vm.enabledSubmitBtn = true;
									} else {
										var isAllSuccess = 0;
										//提交子表ajax
										var submitChildRequest = function(iNum, fininshCallBack) {
											if (requestChildList.length == 0) {
												fininshCallBack();
											}
											console.log(requestChildList)
											console.log(requestChildList[iNum])
											requestChildList[iNum].promise.then(function(data) {
												isAllSuccess++;
												vm.childPageInit(vm.childFormList[iNum]);
												vm.childFormList[iNum].crud.create = [];
												vm.childFormList[iNum].crud.update = [];
												vm.childFormList[iNum].crud.delete = [];
												iNum = iNum + 1;
												if (iNum < requestChildList.length) {
													submitChildRequest(iNum, fininshCallBack);
												} else {
													fininshCallBack();
												}
											}, function(data) {
												isSuccess = false;
												isAllSuccess++;
												iNum = iNum + 1;
												if (iNum < requestChildList.length) {
													submitChildRequest(iNum + 1,
														fininshCallBack);
												} else {
													fininshCallBack();
												}
											});
										}

										submitChildRequest(0, function() {
											if (isSuccess) {
												uni.showToast({
													title: "保存成功",
													icon: 'success'
												});

												vm.deleteTableData(vm.idByDraftList);
												uni.$emit('refreshDraftInfo');
												//刷新整体表单
												vm.initConfig(vm.detailName);
											} else {
												vm.enabledSubmitBtn = true;
											}
											if (typeof(callBackEvent) == 'function') {
												callBackEvent();
												vm.enabledSubmitBtn = true;
											}
											if (vm.crudList[0].finishSql) {
												// 		let formData = $.extend(vm.formData, {
												// 			sql: vm.crudList[0].finishSql
												// 		});
												// 		$.ajax({
												// 			url: "http://" + APP.serverIP() +
												// 				"/SQLData/QuerySql",
												// 			type: "post",
												// 			dataType: "json",
												// 			async: false,
												// 			data: formData,
												// 			success: function(data) {
												// 				data = data.data;
												// 				if (data.status == 200) {
												// 					if (data.ds.length > 0) {
												// 						vm.$toast(data.ds[0].msg);
												// 					}
												// 				} else {
												// 					vm.$toast(data.msg);

												// 				}
												// 			}
												// 		});
											}

										})
									}
								}, function(data) {
									console.log(data)
									vm.enabledSubmitBtn = true;
								});
							}
						} else {
							vm.enabledSubmitBtn = false;
							//带有Js脚本的，则先执行脚本
							if (vm.crudList[1].script) {
								eval(vm.crudList[1].script);
							}
							//任何保存前先调用主表验证SQL
							var checkSQL = vm.crudList[1].sql;
							var isCheck = true;

							if (checkSQL) {
								var postData = Object.assign({
									tableName: vm.physicalTableName,
									keyValue: vm.keyValue,
									updateWorkSQL: checkSQL
								}, vm.formData);
								vm.Request.requestByUrl("/SQLData/UpdateSingleRowByRollBack", postData,
									function() {
										var valitedResult = vm.valitedRequired();
										if (valitedResult.status == 500) {
											uni.showToast({
												title: valitedResult.msg,
												icon: 'error'
											});
											vm.enabledSubmitBtn = true;
										} else {
											vm.Request.requestByUrl("/SQLData/UpdateSingleRow", postData,
												function(data) {
													//子表提交（使用同步提交,数量少的情况下提交）
													var isSuccess = true;
													var requestChildList = [];
													var errorStr = '';
													for (var i = 0; i < vm.childFormList.length; i++) {
														if (vm.childFormList[i].crud.create.length > 0 ||
															vm.childFormList[i].crud.update.length > 0 ||
															vm.childFormList[i].crud.delete.length > 0) {
															console.log(vm.childFormList[i].crud.create);
															console.log(vm.childFormList[i].crud.update);
															//验证必填项
															var result = vm.valitedChildForm(vm
																.childFormList[i], vm.childFormList[i]
																.crud.create, vm.childFormList[i].crud
																.update);
															if (result.valited) {
																var createObj = JSON.parse(JSON.stringify(
																	vm.childFormList[i].crud.create
																));
																createObj.colInfo = [];
																var updateObj = JSON.parse(JSON.stringify(
																	vm.childFormList[i].crud.update
																));
																updateObj.colInfo = [];
																var deleteObj = JSON.parse(JSON.stringify(
																	vm.childFormList[i].crud.delete
																));
																deleteObj.colInfo = [];
																requestChildList.push(vm.Request
																	.PromiseRequestByUrl(
																		"/FormList/SaveData_uniapp", {
																			tableName: vm
																				.childFormList[i]
																				.params
																				.physicalTableName,
																			createStr: JSON.stringify(
																				createObj),
																			updateStr: JSON.stringify(
																				updateObj),
																			deleteStr: JSON.stringify(
																				deleteObj),
																			createWork: vm
																				.childFormList[i]
																				.crudList[0].sql,
																			updateWork: vm
																				.childFormList[i]
																				.crudList[1].sql,
																			deleteWork: vm
																				.childFormList[i]
																				.crudList[2].sql
																		}));



																// vm.Request.requestByUrl("/FormList/SaveData",{
																// 		tableName: vm.childFormList[i].params.physicalTableName,
																// 		createStr: JSON.stringify(vm.childFormList[i].crud.create),
																// 		updateStr: JSON.stringify(vm.childFormList[i].crud.update) ,
																// 		deleteStr: JSON.stringify(vm.childFormList[i].crud.delete),
																// 		createWork: vm.childFormList[i].crudList[0].sql,
																// 		updateWork: vm.childFormList[i].crudList[1].sql,
																// 		deleteWork: vm.childFormList[i].crudList[2].sql
																// 	},function(data){
																// 		if (data.status == 500) {
																// 			vm.$toast(data.msg);
																// 			isSuccess = false;
																// 		} else {
																// 			//vm.childPageInit(vm.childFormList[i]);
																// 			vm.childFormList[i].crud.create = [];
																// 			vm.childFormList[i].crud.update = [];
																// 			vm.childFormList[i].crud.delete = [];
																// 		}
																// 	})
															} else {
																errorStr += result.valitedColumn + "不能为空!";
																isSuccess = false;
															}
														}
													}
													if (!isSuccess) {
														uni.showToast({
															title: errorStr,
															icon: 'error'
														});
														vm.enabledSubmitBtn = true;
													} else {
														var isAllSuccess = 0;
														//提交子表ajax
														var submitChildRequest = function(iNum,
															fininshCallBack) {
															if (requestChildList.length == 0) {
																fininshCallBack();
															}
															requestChildList[iNum].promise.then(
																function(data) {
																	isAllSuccess++;
																	vm.childPageInit(vm
																		.childFormList[iNum]);
																	vm.childFormList[iNum].crud
																		.create = [];
																	vm.childFormList[iNum].crud
																		.update = [];
																	vm.childFormList[iNum].crud
																		.delete = [];
																	iNum = iNum + 1;
																	if (iNum < requestChildList
																		.length) {
																		submitChildRequest(iNum,
																			fininshCallBack);
																	} else {
																		fininshCallBack();
																	}
																},
																function(data) {
																	isSuccess = false;
																	isAllSuccess++;
																	iNum = iNum + 1;
																	if (iNum < requestChildList
																		.length) {
																		submitChildRequest(iNum +
																			1, fininshCallBack);
																	} else {
																		fininshCallBack();
																	}
																});
														}

														submitChildRequest(0, function() {
															if (isSuccess) {
																uni.showToast({
																	title: "保存成功",
																	icon: 'success'
																});
																//刷新整体表单
																//vm.initConfig(vm.detailName);
															} else {
																vm.enabledSubmitBtn = true;
															}
															if (typeof(callBackEvent) ==
																'function') {
																callBackEvent();
															}
															if (vm.crudList[0].finishSql) {
																// 		let formData = $.extend(vm.formData, {
																// 			sql: vm.crudList[0].finishSql
																// 		});
																// 		$.ajax({
																// 			url: "http://" + APP.serverIP() +
																// 				"/SQLData/QuerySql",
																// 			type: "post",
																// 			dataType: "json",
																// 			async: false,
																// 			data: formData,
																// 			success: function(data) {
																// 				data = data.data;
																// 				if (data.status == 200) {
																// 					if (data.ds.length > 0) {
																// 						vm.$toast(data.ds[0].msg);
																// 					}
																// 				} else {
																// 					vm.$toast(data.msg);

																// 				}
																// 			}
																// 		});
															}
															vm.enabledSubmitBtn = true;

														})
													}
												},
												function(data) {
													vm.enabledSubmitBtn = true;
												});
										}
									},
									function(data) {
										vm.enabledSubmitBtn = true;
									})
							}
						}
					}, 0)
				}
			},
			//数据变化的回调函数
			dataChange: function(formCol, returnValue) {
				if (formCol.baseProperty.controlCallBack) {
					var script = formCol.baseProperty.controlCallBack.replace(/\['/g, "vm.formData['");
					script = script.replace(/\["/g, "vm.formData[\"");
					eval(script);
					vm.refreshInitActualName();
				}
				if (formCol.baseProperty.controlChange) {
					var script = formCol.baseProperty.controlChange.replace(/\['/g, "vm.formData['");
					script = script.replace(/\["/g, "vm.formData[\"");
					eval(script);
					vm.refreshInitActualName();
				}
				//判断当前列是否是下属列
				vm.childFormList.forEach(function(childForm) {
					if (childForm.transParams.indexOf(formCol.baseProperty.controlName) >= 0) {
						vm.transParamsDefault();
					}
				})


			},
			itemDataChange: function(formCol, curRow, childForm, returnValue) {
				//更新修改行数据
				//vm.updateRow(curRow);
				if (formCol.colCallBack) {
					var script = formCol.colCallBack.replace(/\['/g, "curRow['");
					script = script.replace(/\["/g, "curRow[\"");
					eval(script);
				}
				if (formCol.colChange) {
					var script = formCol.colChange.replace(/\['/g, "curRow['");
					script = script.replace(/\["/g, "curRow[\"");
					eval(script);
				}
				//刷新子表
				vm.refreshEditValueCol(vm.editFrame);
				vm.$forceUpdate();
			},
			//主表自定义业务按钮事件
			selfWorkHandler(work) {
				if (!vm.enabledSubmitBtn) {
					return;
				} else {
					vm.enabledSubmitBtn = false;

					function task1() {
						return new Promise((resolve, reject) => {
							// console.log(vm.ButtonInfo.script)

							var script = work.script.replace(/\['/g, "vm.formData['");
							script = script.replace(/\["/g, "vm.formData[\"");
							eval(script);

							resolve();
						});
					}

					function task2() {
						return new Promise((resolve, reject) => {
							uni.$emit('FormInitToRefresh', {
								keyID: vm.formData[vm.keyName]
							})
							resolve();
						});
					}

					task1().then(() => {
						return task2();
					}).then(() => {

						uni.$emit('refreshDraftInfo')
						vm.$utils.hideLoading();
					}).catch((error) => {
						vm.$utils.hideLoading();
						uni.showToast({
							title: error,
							icon: 'error'
						})
						console.error('An error occurred:', error);
					});

					// var script = work.script.replace(/\['/g, "vm.formData['");
					// script = script.replace(/\["/g, "vm.formData[\"");
					// await eval(script);

					// console.log(vm.formData[vm.keyName])
					// await uni.$emit('FormInitToRefresh', {
					// 	keyID: vm.formData[vm.keyName]
					// })
				}
			},
			//自定义子表业务按钮事件
			selfChildWorkHandler(work, currentRow) {
				if (!vm.enabledSubmitBtn) {
					return;
				} else {
					vm.enabledSubmitBtn = false;
					var script = work.script.replace(/\['/g, "currentRow['");
					script = script.replace(/\["/g, "currentRow[\"");
					eval(script);
				}

			},
			//重新刷新最新值，用于change或者其他数据更改后
			refreshInitActualName: function() {
				for (var i = 0; i < vm.formDesign.length; i++) {
					//日期控件，格式化内容
					if (vm.formDesign[i].baseProperty.controlType == 'datepicker') {
						vm.formData[vm.formDesign[i].baseProperty.controlName] = vm.formatterDate(vm.formData[vm
							.formDesign[i].baseProperty.controlName], (vm.formDesign[i].controlProperty.date &&
							vm.formDesign[i].controlProperty.date.type) ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd");
					}
					if (vm.formDesign[i].baseProperty.controlType == "select") {
						//下拉框数据加载
						if (vm.formDesign[i].controlProperty.select.type < 3) {
							var sql = vm.formDesign[i].controlProperty.select.dataSource;

							var formDesignObj = vm.formDesign[i];
							vm.dealSelectDatasource(sql, formDesignObj);
						} else if (vm.formDesign[i].controlProperty.select.type == 3) {
							if (vm.formDesign[i].controlProperty.select.chooseType == 1) {
								var valueList = [];
								if (vm.formData[vm.formDesign[i].baseProperty.controlName] != undefined && vm.formData[
										vm.formDesign[i].baseProperty.controlName] !== "") {
									valueList.push("'" + vm.formData[vm.formDesign[i].baseProperty.controlName] + "'");
								}
								var sql = "select * from (" + vm.formDesign[i].controlProperty.select.dataSource +
									")t";
								if (valueList.length > 0) {
									sql += " where " + vm.formDesign[i].controlProperty.select.hiddenValue + " in (" +
										valueList.join(',') + ") ";
									var formDesignObj = vm.formDesign[i];
									vm.dealSelectDatasourceByTree(sql, formDesignObj);
								} else {
									vm.$set(vm.formDesign[i].controlProperty.select, "sqlDataSource", []);
									vm.$set(vm.formDesign[i].controlProperty.select, "originDataSource", []);
									vm.$set(vm.formDesign[i].controlProperty.select, "actualName", "");
									vm.formData[vm.formDesign[i].baseProperty.controlName + '_show'] = '';
								}
							} else {
								var valueList = "";
								if (vm.formData[vm.formDesign[i].baseProperty.controlName] != undefined && vm.formData[
										vm.formDesign[i].baseProperty.controlName] !== "") {
									let valueArray = [];
									valueArray = vm.formData[vm.formDesign[i].baseProperty.controlName].toString()
										.split(',');
									for (var q = 0; q < valueArray.length; q++) {
										valueArray[q] = "'" + valueArray[q] + "'";
									}
									valueList = valueArray.join(',');
								}
								var formDesignObj = vm.formDesign[i];
								var sql = "select * from (" + vm.formDesign[i].controlProperty.select.dataSource +
									")t";
								if (valueList) {
									sql += " where " + vm.formDesign[i].controlProperty.select.hiddenValue + " in (" +
										valueList + ") ";
									vm.dealSelectDatasourceByTree(sql, formDesignObj);
								} else {
									vm.$set(vm.formDesign[i].controlProperty.select, "actualName", "");
									vm.$set(vm.formDesign[i].controlProperty.select, "sqlDataSource", []);
									//vm.formDesign[i].controls[j].controlProperty.select["sqlDataSource"] = [];
									vm.$set(vm.formDesign[i].controlProperty.select, "originDataSource", []);
									vm.formData[vm.formDesign[i].baseProperty.controlName + '_show'] = ''
								}
							}
						}
					}
					// if (options.formDesign[i].baseProperty.controlType == "fileUpload") {
					// 	console.log(vm.formData[options.formDesign[i].baseProperty.controlName]);
					// 	vm.formData[options.formDesign[i].baseProperty.controlName + '_files'] = vm.uploaderImg(vm
					// 		.formData[options.formDesign[i].baseProperty.controlName]);
					// 	console.log(JSON.stringify(vm.formData))
					// }
				}
			},
			post(sql, param, callBack) {
				param["sql"] = sql;
				if (vm.Request.getUserInfo()) {
					if (!param.hasOwnProperty("P_UserID")) {
						param.P_UserID = vm.Request.getUserInfo().UserID;
					}
					if (!param.hasOwnProperty("P_UserName")) {
						param.P_UserName = vm.Request.getUserInfo().UserName;
					}
					if (!param.hasOwnProperty("P_UserCode")) {
						param.P_UserCode = vm.Request.getUserInfo().UserCode;
					}
				}
				vm.Request.requestByUrl("/SQLData/QuerySql", param, function(data) {
					callBack(data);
				}, function(err) {
					console.log(err)
				});
				//vm.handleSizeChange(vm.paging.pageIndex);
			},
			/*系统函数结束*/
			/*change获取数据机制处理
			  用于change过程中反复调用后台处理的机制问题
			*/
			changeDataAjax: function(datasource, query, callBack, requestObj) {
				var dsResult = vm.changeDataSource.filter(function(item) {
					return item.datasource == datasource && item.query == query;
				});
				if (dsResult.length == 0) {
					var returnData = [];
					var sql = "select * from (" + datasource + ")t";
					sql += " where " + query;

					var ajaxRequest = vm.Request.PromiseRequestByUrl('/SQLData/GetDataBySql', {
						sql: sql
					});

					ajaxRequest.promise.then(function(data) {
						if (data.status == 200) {
							returnData = data.data.ds;
							vm.changeDataSource.push({
								datasource: datasource,
								query: query,
								data: returnData
							});
							callBack(returnData, requestObj);
						}
					});
				} else {
					callBack(dsResult[0].data, requestObj);
				}
			},
			//系统默认常量时间
			getSYDefaultValue(funcName) {
				if (funcName.indexOf("getdate()") >= 0) {
					var date;
					if (funcName == "getdate()") {
						date = new Date();
					} else {
						date = new Date();
						Date.prototype.DateAdd = function(strInterval, Number) {
							var dtTmp = this;
							switch (strInterval) {
								case 's':
									return new Date(Date.parse(dtTmp) + (1000 * Number));
								case 'n':
									return new Date(Date.parse(dtTmp) + (60000 * Number));
								case 'h':
									return new Date(Date.parse(dtTmp) + (3600000 * Number));
								case 'd':
									return new Date(Date.parse(dtTmp) + (86400000 * Number));
								case 'w':
									return new Date(Date.parse(dtTmp) + ((86400000 * 7) * Number));
								case 'q':
									return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number * 3, dtTmp
										.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
								case 'm':
									return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number, dtTmp.getDate(),
										dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
								case 'y':
									return new Date((dtTmp.getFullYear() + Number), dtTmp.getMonth(), dtTmp.getDate(),
										dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
							}
						}
						var addFun = funcName.split('.')[1];
						eval("date=date." + addFun);
					}
					var seperator1 = "-";
					var seperator2 = ":";
					var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
					var strDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
					var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
						" " + date.getHours() + seperator2 + date.getMinutes() +
						seperator2 + date.getSeconds();
					return currentdate;
				} else if (funcName.indexOf("$.cookie") >= 0) {
					return eval(funcName);
				} else if (funcName.indexOf('func:') >= 0) {
					return eval(funcName.split(':')[1]);
				} else if (funcName.indexOf("@") >= 0) {
					if (funcName == '@P_UserID') {
						return {
							P_UserID: this.$store.state.UserInfo.UserID,
							P_UserName: this.$store.state.UserInfo.UserName
						}
					} else if (funcName == '@EmplID') {
						return {
							P_UserID: this.$store.state.UserInfo.EmplID,
							P_UserName: this.$store.state.UserInfo.UserName
						}
					}
				} else if (funcName.indexOf('localStorage.getItem') >= 0) {
					return eval(funcName);
				} else {
					return funcName;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	* {
		box-sizing: border-box;
	}


	.u-popup {
		flex: initial !important;
	}

	.content1 {
		display: flex;
		flex-direction: column;
		height: 100vh;
		background-color: #f9f9f9;

		.MainBox1 {
			// flex: 1;
			height: 38.2vh !important;
			overflow: auto;
			// padding: 10px;

			// 表单1
			.u-form {
				// padding: 0px 10px;

				.u-form-item {
					background-color: #fff;
					padding: 0 16px;
				}


				.TopOption {

					.u-form-item__body {
						flex-direction: column !important;
					}
				}

			}
		}

		.content_main {
			flex: 1;
			// height: 300px !important;
			// overflow: auto;
			position: relative;


			.TopCard {
				background-color: #4499ec;

				.CardInfo {
					flex: 3;
				}

				.CardTag {
					position: absolute;
					right: 20px;
					top: 25rpx;

				}
			}
		}


		.DetailBox {
			height: 61.8vh !important;
			background-color: #fff;
		}

		.DetailBoxFull {
			height: 100vh !important;
			background-color: #fff;
		}

	}

	.content_bottom1 {
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		height: 70px;
		line-height: 70px;
		padding: 6px 15px;
		border-top: 1px solid #efefef;

		.workBtn {
			border-color: #ddd !important;
			margin-left: 10px !important;
		}
	}

	.mainForm {
		height: 38.2vh;
		overflow-y: auto;
	}

	.van-badge {
		margin: 0px 5px;
		background-color: #51d0d0;
		color: #fff;
		display: block;
		min-width: 25px;
		height: 25px;
		line-height: 25px;
		// padding: 3px;
		float: left;
		vertical-align: middle;
		border-radius: 8px;
		text-align: center;
	}

	.editDetail {
		max-height: 50vh;
		overflow-y: auto;
		padding: 5px;
	}

	.Main_CardListBox {
		height: calc(61.8vh - 90px);
		overflow: auto;
	}

	.Main_CardListBoxFull {
		height: calc(100vh - 220px);
		overflow: auto;
	}

	.childBtns {
		width: 100%;
		padding: 0 0 10px;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
</style>